(function(vc){
    vc.extends({
        propTypes: {
           emitChooseStoreAds:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseStoreAdsInfo:{
                storeAdss:[],
                _currentStoreAdsName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseStoreAds','openChooseStoreAdsModel',function(_param){
                $('#chooseStoreAdsModel').modal('show');
                $that._refreshChooseStoreAdsInfo();
                $that._loadAllStoreAdsInfo(1,10,'');
            });
        },
        methods:{
            _loadAllStoreAdsInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('storeAds.listStoreAdss',
                             param,
                             function(json){
                                var _storeAdsInfo = JSON.parse(json);
                                $that.chooseStoreAdsInfo.storeAdss = _storeAdsInfo.storeAdss;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseStoreAds:function(_storeAds){
                if(_storeAds.hasOwnProperty('name')){
                     _storeAds.storeAdsName = _storeAds.name;
                }
                vc.emit($props.emitChooseStoreAds,'chooseStoreAds',_storeAds);
                vc.emit($props.emitLoadData,'listStoreAdsData',{
                    storeAdsId:_storeAds.storeAdsId
                });
                $('#chooseStoreAdsModel').modal('hide');
            },
            queryStoreAdss:function(){
                $that._loadAllStoreAdsInfo(1,10,$that.chooseStoreAdsInfo._currentStoreAdsName);
            },
            _refreshChooseStoreAdsInfo:function(){
                $that.chooseStoreAdsInfo._currentStoreAdsName = "";
            }
        }

    });
})(window.vc);
